﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Data;
using DAL;
using Model;
namespace BLL
{
    public class UserBLL
    {
        public static DataTable selectAllbooks()
        {
            return UserServer.selectAllBooks().Tables[0];
        }
        public static int addBook(bookinfo bi)
        {
            return Convert.ToInt32(UserServer.addBook(bi));
        }
        ///根据id查找book
        public static bookinfo selectbook(int id)
        {
            DataTable dt= UserServer.selectBook(id).Tables[0];
            bookinfo bi = new bookinfo();
            bi.Id = id;
            bi.Title = dt.Rows[0][0].ToString();
            bi.Decsript= dt.Rows[0][1].ToString();
            bi.Booktype = dt.Rows[0][2].ToString();
            return bi;
      //      bi.Price = dt.Rows[0][3]
        }
        //更新书籍信息
        public static int updateBook(bookinfo bi)
        {
            return Convert.ToInt32(DAL.UserServer.updateBook(bi));
        }
        //删除书籍
        public static int deleteByid(int id)
        {
            return Convert.ToInt32(DAL.UserServer.deleteByid(id));
        }
    }
}
